<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1">
    <title id="jo20941">gpactivatestandby</title>
    <body>
        <p>Activates a standby master host and makes it the active master for the Greenplum Database
            system.</p>
        <section id="section2">
            <title>Synopsis</title>
            <codeblock>gpactivatestandby [-d &lt;standby_master_datadir>] [-f] [-a] [-q] 
    [-l &lt;logfile_directory>]

gpactivatestandby -v 

gpactivatestandby -? | -h | --help</codeblock>
        </section>
        <section id="section3">
            <title>Description</title>
            <p>The <codeph>gpactivatestandby</codeph> utility activates a backup, standby master
                host and brings it into operation as the active master instance for a Greenplum
                Database system. The activated standby master effectively becomes the Greenplum
                Database master, accepting client connections on the master port. </p>
            <p>When you initialize a standby master, the default is to use the same port as the
                active master. For information about the master port for the standby
                master, see <xref href="./gpinitstandby.xml#topic1" type="topic" format="dita"
                />. </p>
            <p>You must run this utility from the master host you are activating, not the
                failed master host you are disabling. Running this utility assumes you have a
                standby master host configured for the system (see <xref
                    href="./gpinitstandby.xml#topic1" type="topic" format="dita"/>).</p>
            <p>The utility will perform the following steps:</p>
            <ul>
                <li id="jo140686">Stops the synchronization process (<codeph>walreceiver</codeph>)
                    on the standby master</li>
                <li id="jo140687">Updates the system catalog tables of the standby master using the
                    logs</li>
                <li id="jo140409">Activates the standby master to be the new active master for the
                    system</li>
                <li id="jo141105">Restarts the Greenplum Database system with the new master
                    host</li>
            </ul>
            <p>A backup, standby Greenplum master host serves as a 'warm standby' in the event of
                the primary Greenplum master host becoming non-operational. The standby master is
                kept up to date by transaction log replication processes (the
                    <codeph>walsender</codeph> and <codeph>walreceiver</codeph>), which run on the
                primary master and standby master hosts and keep the data between the primary and
                standby master hosts synchronized. </p>
            <p>If the primary master fails, the log replication process is shutdown, and the standby
                master can be activated in its place by using the <codeph>gpactivatestandby</codeph>
                utility. Upon activation of the standby master, the replicated logs are used to
                reconstruct the state of the Greenplum master host at the time of the last
                successfully committed transaction. </p>
            <p>In order to use <codeph>gpactivatestandby</codeph> to activate a new primary master
                host, the master host that was previously serving as the primary master cannot be
                running. The utility checks for a <codeph>postmaster.pid</codeph> file in the data
                directory of the disabled master host, and if it finds it there, it will assume the
                old master host is still active. In some cases, you may need to remove the
                    <codeph>postmaster.pid</codeph> file from the disabled master host data
                directory before running <codeph>gpactivatestandby</codeph> (for example, if the
                disabled master host process was terminated unexpectedly).</p>
            <p>After activating a standby master, run <codeph>ANALYZE</codeph> to update the
                database query statistics. For example:</p>
            <codeblock>psql &lt;dbname> -c 'ANALYZE;'</codeblock>
            <p>After you activate the standby master as the primary master, the Greenplum
                Database system no longer has a standby master configured. You might want to
                specify another host to be the new standby with the <xref
                    href="./gpinitstandby.xml#topic1" type="topic" format="dita"/> utility. </p>
        </section>
        <section id="section4">
            <title>Options</title>
            <parml>
                <plentry>
                    <pt>-a (do not prompt)</pt>
                    <pd>Do not prompt the user for confirmation.</pd>
                </plentry>
                <plentry>
                    <pt>-d <varname>standby_master_datadir</varname></pt>
                    <pd>The absolute path of the data directory for the master host you are
                        activating.</pd>
                    <pd>If this option is not specified, <codeph>gpactivatestandby</codeph> uses the
                        value of the 
                            <codeph>MASTER_DATA_DIRECTORY</codeph> environment variable setting on the master host you are
                        activating. If this option is specified, it overrides any setting of <codeph>MASTER_DATA_DIRECTORY</codeph>. </pd>
                    <pd>If a directory cannot be determined, the utility returns an error. </pd>
                </plentry>
                <plentry>
                    <pt>-f (force activation)</pt>
                    <pd>Use this option to force activation of the backup master host. Use this
                        option only if you are sure that the standby and primary master hosts are
                        consistent.</pd>
                </plentry>
                <plentry>
                    <pt>-l <varname>logfile_directory</varname></pt>
                    <pd>The directory to write the log file. Defaults to
                            <codeph>~/gpAdminLogs</codeph>.</pd>
                </plentry>
                <plentry>
                    <pt>-q (no screen output)</pt>
                    <pd>Run in quiet mode. Command output is not displayed on the screen, but is
                        still written to the log file.</pd>
                </plentry>
                <plentry>
                    <pt>-v (show utility version)</pt>
                    <pd>Displays the version, status, last updated date, and check sum of this
                        utility.</pd>
                </plentry>
                <plentry>
                    <pt>-? | -h | --help (help)</pt>
                    <pd>Displays the online help.</pd>
                </plentry>
            </parml>
        </section>
        <section id="section5">
            <title>Example</title>
            <p>Activate the standby master host and make it the active master instance for a
                Greenplum Database system (run from backup master host you are activating):</p>
            <codeblock>gpactivatestandby -d /gpdata</codeblock>
        </section>
        <section id="section6">
            <title>See Also</title>
            <p><xref href="./gpinitsystem.xml#topic1" type="topic" format="dita"/>, <xref
                    href="./gpinitstandby.xml#topic1" type="topic" format="dita"/></p>
        </section>
    </body>
</topic>
